﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class FinanceCenter_FinanceIndex : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.lbUserName.Text = _User.RealityName;
            BindAccountBaseInfo();
            BindanagerLoginInfo();

            //Log log = new Log();
            //log.UserID = _User.ID;
            //log.Operate = _User.RealityName + "登录到财务中心";
            //log.UserIp = _User.LoginIP;
            //log.EditLog();
        }
    }

    #region Web 窗体设计器生成的代码

    override protected void OnInit(EventArgs e)
    {
        isRequestLogin = true;
        RequestCompetences = Competences.BuildCompetencesList(Competences.Finance);
        RequestLoginPage = "FinanceCenter/FinanceIndex.aspx";

        base.OnInit(e);
    }

    #endregion

    private void BindAccountBaseInfo()
    {
        long RegTotal = 0; 
        long DayRegCount= 0; 
        double TotalGathering= 0; 
        double PayTota= 0; 
        double DayBuy= 0; 
        double HistoryBuy= 0; 
        double CurPlayRatio= 0;

        if (DAL.Procedures.P_GetAccountBaseInfo.Call(ref RegTotal, ref DayRegCount, ref TotalGathering, ref PayTota, ref DayBuy, ref HistoryBuy, ref CurPlayRatio) < 0)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "数据库连接错误");

            return;
        }

        this.lbRegTotal.Text = RegTotal.ToString();
        this.lbDayRegCount.Text = DayRegCount.ToString();
        this.lblTotalGathering.Text = (ShoveEL._Convert.StrToDouble(TotalGathering.ToString(), 0) == 0) ? "0.00" : ShoveEL._Convert.StrToDouble(TotalGathering.ToString(), 0).ToString("N");
        this.lbPayTotal.Text = (ShoveEL._Convert.StrToDouble(PayTota.ToString(), 0) == 0) ? "0.00" : ShoveEL._Convert.StrToDouble(PayTota.ToString(), 0).ToString("N");
        this.lbDayBuy.Text = (ShoveEL._Convert.StrToDouble(DayBuy.ToString(), 0) == 0) ? "0.00" : ShoveEL._Convert.StrToDouble(DayBuy.ToString(), 0).ToString("N");
        this.lbHistoryBuy.Text = (ShoveEL._Convert.StrToDouble(HistoryBuy.ToString(), 0) == 0) ? "0.00" : ShoveEL._Convert.StrToDouble(HistoryBuy.ToString(), 0).ToString("N");
        double PlayRatio = ShoveEL._Convert.StrToDouble(CurPlayRatio.ToString(), 0.00);
        ibRatio.Width = (Unit)(PlayRatio * 100 * 3);
        lbText.Text = (PlayRatio * 100) + "%";

        if (PlayRatio > ShoveEL._Convert.StrToDouble(DAL.Functions.F_GetOptions.Call("系统警示提示条件值"), 0))
        {
            labEarlyWarning.Visible = true;
            labEarlyWarning.Text = "警报拉响";
        }
    }

    private void BindanagerLoginInfo()
    {
        long ManagerCount = 0;
        string AferUser = "";
        string AfterIp = "";
        DateTime LoginAfterTime = DateTime.Now;
        string UserIp = "";
        DateTime UserLoginTime = DateTime.Now;

        if (DAL.Procedures.P_GetManagerLoginInfo.Call(_User.ID, ref ManagerCount,ref AferUser, ref AfterIp, ref LoginAfterTime, ref UserIp, ref UserLoginTime) < 0)
        {
            ShoveEL._Web.JavaScript.Alert(this.Page, "数据库连接错误");

            return;
        }

        this.lbManagerCount.Text = ManagerCount.ToString();
        this.lbAferUser.Text = AferUser;
        this.lbAfterIp.Text = AfterIp;
        this.lbLoginAfterTime.Text = LoginAfterTime.ToString();
        this.lbUserIp.Text = UserIp.ToString();
        this.lbUserLoginTime.Text = UserLoginTime.ToString();
    }
}
